/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.assets;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Timer;
import java.util.Vector;

/**
 *
 * @author Jarrod Risley
 */
public class ArmSwitchPair {
    
    /*
     * Global Class Variables
     */
    private DigitalInput topChannel;
    private DigitalInput bottomChannel;
    
    public static final int ON_OFF = 1;
    public static final int OFF_ON = 2;
    
    private static final int STATE_ARRAY_CUTOFF = 2;
    
    
    // CONSTRUCTOR // 
    
    
    public ArmSwitchPair(int sidecarNum, int ioChannelone, int ioChannelTwo) {
        
        topChannel = new DigitalInput(sidecarNum, ioChannelone);
        bottomChannel = new DigitalInput(sidecarNum, ioChannelTwo);
        
    } // end ArmSwitchPair channel
    
    
    // METHODS //
    
    /**
     * Checks the top switch to see if it has been pressed.
     * @return True if pressed.
     */
    public boolean getTopInput() {
        return !topChannel.get();
    } // end getTopInput
    
    /**
     * Checks the bottom switch to see if it has been pressed.
     * @return True if pressed.
     */
    public boolean getInput() {
        
        if (!topChannel.get() || !bottomChannel.get())
            return true;
        
        return false;
        
    } // end getInput
    
    /**
     * Grabs the top channel.
     * @return The channel of the the top switch.
     */
    public int getTopChannel() {
        return topChannel.getChannel();
    } // end getTopChannel
    
    /**
     * Grabs the bottom channel.
     * @return The channel of the bottom switch.
     */
    public int getBottomChannel() {
        return bottomChannel.getChannel();
    } // end getBottomChannel
    
    public boolean didChangeRequestedState(boolean oldState) {
        
        if (oldState != getInput()) {
            
            System.out.println("Old state does not equal the new!");
            return true;
            
        } // end didChangeRequestedState
            
        return false;
        
    } // end didChangeState 
    
    /**
     * Gets the falling edge of the square wave.
     * 
     * @param oldState The state to measure before.
     * @return True if the have picked up a falling edge.
     */
    public boolean fallingEdge(boolean oldState) {
        
        if (oldState == true && getInput() == false)
            return true;
        else
            return false;
        
    } // end fallingEdge
    
    public boolean risingEdge(boolean oldState) {
        
        if (oldState == false && getInput() == true)
            return true;
        else
            return false;
        
    } // end risingEdge
    
} // end ArmSwitchPair
